import cv2
def detectAndDescribe(image):
    gray =cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
    sift=cv2.SIFT.create()
    kp,des=sift.detectAndCompute(gray,None)
    return image,kp,des
imgA=cv2.imread('left_01.jpg')
imgB=cv2.imread('right_01.jpg')
imgA,kpA,desA=detectAndDescribe(imgA)
imgB,kpB,desB=detectAndDescribe(imgB)
index_params=dict(algorithm=1,trees=5)
search_params=dict(checks=50)
flann=cv2.FlannBasedMatcher(index_params,search_params)
rawMatches=flann.knnMatch(desA,desB,k=2)
ratio=0.7
matches=[[m]for m,n in rawMatches if m.distance<ratio*n.distance]
out=cv2.drawMatchesKnn(imgA,kpA,imgB,kpB,matches[:50],None)
cv2.imshow('drawMatchers',out)
cv2.waitKey()
cv2.destroyAllWindows()